<?php

namespace App\Modules\Address;

use App\Modules\AdapterApi;
use App\Services\Address\AddressIndex;

/**
 * 地址应用层
 * Class ApiAddress
 * @package App\Modules\Address
 */
class ApiAddress extends AdapterApi
{
    // 添加新地区
    public function createAddress()
    {
        $data = pick_array($this->postData,["pid", "name", "py_name", "zipcode", "type", "special", "order"]);

        return AddressIndex::Address()->createAddress($data);
    }

    // 编辑地区信息
    public function editAddress(): array
    {

        $data = pick_array($this->postData,["id","pid", "name", "py_name", "zipcode", "type", "special", "order"]);

        return AddressIndex::Address()->editAddress($data);
    }

    // 全部地区列表获取
    public function addressList()
    {
        return AddressIndex::Address()->addressList();
    }

    // 某一类地区列表获取
    public function someAddressList()
    {
        $data = pick_array($this->postData,['pid']);

        return AddressIndex::Address()->someAddressList($data);
}
}